from django.db import models
from django.conf import settings

class Material(models.Model):
    MATERIAL_TYPES = [
        ('image', '图片'),
        ('video', '视频'),
    ]

    user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, verbose_name='广告主')
    material_type = models.CharField(max_length=10, choices=MATERIAL_TYPES, verbose_name='素材类型')
    file = models.FileField(upload_to='materials/%Y/%m/%d/', verbose_name='素材文件')
    upload_time = models.DateTimeField(auto_now_add=True, verbose_name='上传时间')

    def __str__(self):
        return f"{self.user.username} - {self.get_material_type_display()} - {self.upload_time.strftime('%Y-%m-%d %H:%M:%S')}"